//
//  SafeCenterViewController.m
//  联付商圈
//
//  Created by apple on 2017/10/31.
//  Copyright © 2017年 lianfu. All rights reserved.
//

#import "SafeCenterViewController.h"

@interface SafeCenterViewController ()
@property (nonatomic, strong) UIScrollView *safeScrollView;
@end

@implementation SafeCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self buildMainInterface];
}

- (void)buildMainInterface
{
    [self.navigationItem setTitle:@"安全中心"];
    
    self.safeScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREENW, SCREENH - 113)];
    self.safeScrollView.contentSize = CGSizeMake(SCREENW, SCREENH - 64);
    [self.view addSubview:_safeScrollView];
    
    [self addCellOnSafeScrollViewByFrame:CGPointMake(22 * FONTSIZE, 18) Tag:0 Title:@"重置登录密码"];
    [self addCellOnSafeScrollViewByFrame:CGPointMake(22 * FONTSIZE, 73) Tag:1 Title:@"重置支付密码"];
}

- (void)addCellOnSafeScrollViewByFrame:(CGPoint)frame Tag:(NSInteger)tag Title:(NSString *)title
{
    UIButton *itemButton = [UIButton buttonWithType:UIButtonTypeCustom];
    itemButton.frame = CGRectMake(frame.x, frame.y, SCREENW - 44 * FONTSIZE, 44 * FONTSIZE);
    [itemButton setBackgroundImage:[UIImage imageNamed:@"safeCenterCell@2x"] forState:UIControlStateNormal];
    itemButton.tag = tag;
    [itemButton addTarget:self action:@selector(turnToModifyPasswordVCByButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.safeScrollView addSubview:itemButton];
    
    UIImageView *arrowImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow@2x"]];
    arrowImgView.frame = CGRectMake(301 * FONTSIZE, 16 * FONTSIZE, 6 * FONTSIZE, 10 * FONTSIZE);
    [itemButton addSubview:arrowImgView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(29 * FONTSIZE, 14 * FONTSIZE, 120 * FONTSIZE, 14 * FONTSIZE)];
    titleLabel.text = title;
    titleLabel.font = [UIFont systemFontOfSize:14 * FONTSIZE];
    [itemButton addSubview:titleLabel];
}

- (void)turnToModifyPasswordVCByButton:(UIButton *)sender
{
    ModifyPasswordViewController *passwordVC = [[ModifyPasswordViewController alloc] init];
    passwordVC.payOrLogin = sender.tag;
    [self.navigationController pushViewController:passwordVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
